Concurrency control in multiprocessing and multithreading systems is an important technique for minimizing the time for which locks are held and the time threads spend idle waiting for other threads to complete tasks. Compare and swap (CASN) operations, such as compare and swap word (CAS1) instructions, are often used to implement locks to protect data structures in memory against concurrent access. CAS1 is a common instruction that atomically compares the content of a memory location to a first value. If the content and the first value are the same, the CAS l instruction replaces the content of the memory location with a second value.
However, implementing a CASN operation using such a technique would be difficult because comparing the content of all of the memory locations to values before updating the content of the memory locations would be computationally expensive and time-consuming.